<?php
########################################################################################
# Empresa :     Tecnopac Informatica;                                                  #
# Autor:        Deiverson Pacheco;                                                     #
# Data Criação: 10/12/2010;                                                            #
########################################################################################
session_start();
header("Cache-control: private");
include_once("../../includes/session.php");


//Linha para formatação de caracteres com acentuação
header("Content-Type: text/html; charset=ISO-8859-1",true);


//======================================================================================
//==> Include obrigatórias no script
//======================================================================================
include_once('../../includes/classes/class.TemplatePower.php');
include_once('../../includes/classes/class.Conexao.php');
include_once('../../includes/classes/class.Geral.php');

//======================================================================================
//==> Inicializar Classes
//======================================================================================
$not  = new Persist;
$not5 = new Persist;
$data = new getData;
$cor  = new ColorTr;
$util = new Util;
$vld  = new ValidarDados;
$sql  = new SqlInjection;

//======================================================================================
//==> Instanciar TemplatePower para juntar o PHP + HTML
//======================================================================================
$tpl  = new TemplatePower('../../html/geral/popup_contatos_associados.html');
$tpl->prepare();


//======================================================================================
//==> Recebe variaveis de pesquisa
//======================================================================================
$id  = @$_GET['id'];
$tpl->assign('id_pess',$id);

$sql_busca =" and contatos_associados.id_cadastroj = '$id' ";

$cont = 1;

$not->sql = "select cadastro.id, cadastro.nome_razao
			from cadastro
			inner join contatos_associados on cadastro.id = contatos_associados.id_cadastrof
			where contatos_associados.id <> '0' $sql_busca order by cadastro.nome_razao";

if($not->ler()>0){
	while($not->ini()){
		$tpl->newBlock('LOOP');
		$tpl->assign('cont',$cont);
		$cont++;
		$tpl->assign('par_id', $not->id);
		$tpl->assign('nome', $not->nome_razao);
		$tpl->assign('cor', $cor->altColor());
	}
}
$tpl->goToBlock('_ROOT');


//LOOP CATEGORIAS

$not5->sql = " select * from cadastro where pessoa = 1 ";
if ($not5->ler() > 0){
	while($not5->ini()){
	    $tpl->newBlock('ASSO');
        $tpl->assign('id_pess',$not5->id);
        $tpl->assign('npess',$not5->nome_razao);
	}
}
//======================================================================================
//==> Enviar página unificada PHP + HTML
//======================================================================================
$tpl->showUnAssigned( false );  // para debug. na hora de publicar, setar para false
$tpl->printToScreen();
?>